package demo2;

public class Test2 {
    public static void main(String[] args) {


    }

    public String longestCommonPrefix (String[] strs) {
        // write code here
        StringBuffer stringbuffer = new StringBuffer() ;
        int count = 0 ;
        while(true){
            int i = 0 ;
            char ch = strs[0].charAt(count) ;
            for(int j = 1 ; j < strs.length ; j++){
                if(ch != strs[j].charAt(count)){
                    i = 1 ;
                    break ;
                }
            }
            if(i == 0 ){
                stringbuffer.append(strs[0].charAt(count)) ;
                count ++ ;
            }else{
                break ;
            }
        }

        return stringbuffer.toString() ;

    }
}
class A<T >{



}
